const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const base = require('./webpack.base.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const TerserPlugin = require('terser-webpack-plugin');

module.exports = merge(base, {
    devtool: 'source-map',
    mode:'development',
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        // new BundleAnalyzerPlugin(),

    ],
    optimization: {
        minimize: false,
        nodeEnv: process.env.NODE_ENV,
        splitChunks: {
            chunks: 'all',
            minSize: 30000,
            maxSize: 0,
            minChunks: 1,
            maxAsyncRequests: 5,
            maxInitialRequests: 3,
            automaticNameDelimiter: '--',
            automaticNameMaxLength: 30,
            name: true,
            cacheGroups: {
                vendors: {
                    test: /[\\/]node_modules[\\/]/,
                    priority: -10
                },
                default: {
                    minChunks: 2,
                    priority: -20,
                    reuseExistingChunk: true
                }
            }
        }
    },
    devServer: {
        port:3002,
        historyApiFallback: true,
        inline: true,
        hot: true,
        host: 'localhost',
        hotOnly:true,
        proxy:{
            '/':{
                target: 'http://121.229.50.212:8081/',
                changeOrigin: true,
                secure: false,
                pathRewrite: {"^/" : ""}
            }
        }
    }
});
